package com.demo;

public class ThreadDemo {

    /**
     * **
     * ****
     */
    static class ThreadPrintStar extends Thread {
        int printLine;
        String name;

        /**
         * @param line 要打印的行数
         */
        ThreadPrintStar(int line,String name) {
            this.printLine = line;
            this.name = name;
        }

        @Override
        public void run() {
            for (int i = 1; i <= printLine; i++) {
                System.out.print(this.name + "的星号：");
                for (int j = 0; j < 2 * i - 1; j++) {
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }
    static class RunnablePrintStar implements Runnable {
        int printLine;
        String name;

        /**
         * @param line 要打印的行数
         */
        RunnablePrintStar(int line,String name) {
            this.printLine = line;
            this.name = name;
        }

        @Override
        public void run() {
            for (int i = 1; i <= printLine; i++) {
                System.out.print(this.name + "的星号：");
                for (int j = 0; j < 2 * i - 1; j++) {
                    System.out.print("*");
                }
                System.out.println();
            }
        }
    }

    public static void main(String[] args) {
        System.out.println("1");
//        new ThreadPrintStar(5,"1->").start();
//        new ThreadPrintStar(5,"2->").start();
//        RunnablePrintStar r1 = new RunnablePrintStar(4, "r1->");
//        RunnablePrintStar r2 = new RunnablePrintStar(4, "r2->");
//        new Thread(r1).start();//启动
//        new Thread(r2).start();

        System.out.println("2");
    }
}
